const refresh = {
    methods: {
        /**
         * [beforeunloadHandler 浏览器关闭时进行用户提示]
         * @return {[type]} [description]
         */
        beforeunloadHandler(e) {
            // sessionStorage.clear();
            // localStorage.removeItem('userInfo');
            e = e || window.event;
            if (e) {
                e.returnValue = "您是否确认离开此页面-您当前的数据会丢失";
            }
            return "您是否确认离开此页面-您当前的数据会丢失";
        },
    },
    created() {
        this.$router.push({
            name: "Login"
        })
    },
    mounted() {
        window.addEventListener("beforeunload", (e) => {
            this.beforeunloadHandler(e);
            location.href = "/login";
        });
    },
    destroyed() {
        window.removeEventListener("beforeunload", (e) => {
            this.beforeunloadHandler(e);
        });
    },
}

export default refresh